package com.example.administrator.printoutindemo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;

import com.example.administrator.printoutindemo.adapter.MyFragmentPagerAdapter;
import com.example.administrator.printoutindemo.fragment.SenqingpeisongFragment;
import com.example.administrator.printoutindemo.fragment.ShenpifankuiFragment;

import java.util.ArrayList;
import java.util.List;

public class ShenQingPeisongActivity extends AppCompatActivity {
    private List<Fragment> fragments = new ArrayList<Fragment>();
    private ViewPager viewPager;
    private LinearLayout main_goods, main_deal;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.shenqingpeisong);
        viewPager= (ViewPager) findViewById(R.id.viewPager);
        main_deal= (LinearLayout) findViewById(R.id.main_deal);
        main_goods= (LinearLayout) findViewById(R.id.main_goods);
        Fragment oneFragment = new SenqingpeisongFragment();//申请
        Fragment twoFragment = new ShenpifankuiFragment();//反馈;
        fragments.add(oneFragment);
        fragments.add(twoFragment);

        MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments);
        viewPager.setAdapter(adapter);
        viewPager.setOffscreenPageLimit(0);
        viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
            }
        });
        main_deal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                viewPager.setCurrentItem(1);
            }
        });
        main_goods.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                viewPager.setCurrentItem(0);
            }
        });
    }


}
